package org.erp.product.infrastructure.enums;

import lombok.Getter;

/**
 * @author libin
 * @version 1.0
 * @description:
 * @date 2025/11/15 20:23
 **/
@Getter
public enum RepairStatusEnum {
    WAITING_REPAIR(0, "待维修"),
    REPAIRED(1, "已维修"),
    TRANSFERRING(2, "调拨中"),
    REPAIRED_TRANSFERRING(3, "已维修调拨中"),
    CONNECTED(4, "已接驳"),
    WAITING_RECYCLE(5, "待返库"),
    RECYCLED(6, "已返库");

    private final Integer code;
    private final String message;

    RepairStatusEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static Integer getCodeByMessage(String message) {
        for (RepairStatusEnum item : RepairStatusEnum.values()) {
            if (item.getMessage().equals(message)) {
                return item.getCode();
            }
        }
        return null;
    }

    public static String getMessageByCode(Integer code) {
        for (RepairStatusEnum item : RepairStatusEnum.values()) {
            if (item.getCode().equals(code)) {
                return item.getMessage();
            }
        }
        return null;
    }

    public static RepairStatusEnum getByCode(Integer code) {
        for (RepairStatusEnum value : values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }

    public static RepairStatusEnum getByMessage(String message) {
        for (RepairStatusEnum value : values()) {
            if (value.getMessage().equals(message)) {
                return value;
            }
        }
        return null;
    }
}
